package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func login(c *gin.Context) {
	fmt.Printf("请求方法为:%s", c.Request.Method)
	fmt.Println()
	c.String(http.StatusOK, "成功以%s访问该页面", c.Request.Method)
	c.String(http.StatusOK, "以%s路径访问该页面", c.Request.URL)
}

func main() {
	router := gin.Default()
	v1 := router.Group("/v1")
	{
		v1.GET("/login", login)
		v1.POST("/submit")
		v1.POST("/read")
	}

	v2 := router.Group("/v2")
	{
		v2.GET("/login", login)
		v2.POST("/submit")
		v2.POST("/read")
	}
	router.Run()
}
